import * as THREE from "three";
import axios from "axios";
import MyRadar from "../class/MyRadar";
import MyFlyLine from "../class/MyFlyLine";
export const EightExp = {
	methods:{
        async eightExp(){
            this.loading = true;
            this.$parent.btnIsDis = true;
            this.getMapData("worldMap") ;
            var picArr = [
                {imgUrl:"img/relatedPhoto/Eight/Macedonia.jpg" ,imgDesc:"北马其顿加入:北约仪式，北约秘书长延斯·斯托尔滕贝格和北马其顿驻加入北约举行升旗仪式。"},
                {imgUrl:"img/relatedPhoto/Eight/Macedonia2.jpg",imgDesc:"北马其顿加入北约的升旗仪式在盟军司令部作战总部(SHAPE- Mons)同时举行，盟军欧洲最高指挥官托德沃尔特斯将军发表讲话。"},
                {imgUrl:"img/relatedPhoto/Eight/Macedonia3.jpg",imgDesc:"冠状病毒应对:捷克共和国向北马其顿提供援助,捷克军队的军用运输机CASA向北马其顿运送1,000,000个口罩，以应对COVID-19疫情。"}
            ]
            this.changePicTexture(picArr);
            await   this.loadCountryNumber(8);
            var flagAnimation = [];
            var fontAnimation;
            var newCameraPos,newTargetPos ;
            var Group  = new THREE.Group();
            var BalkanAnimation,KosovoAnimation,MacedoniaAnimation,serbiaFontAnimation;
            Group.name = "Jb"
            var resource = new THREE.Group();
            this.scene.add(Group)

            // 加载资源
            // this.radar = new MyRadar({}) ;
            // Group.add(this.radar.group) ;
            var resLine = {x:34.76137696431783,y:4,z:-7.728797077825815}
            var myline = new MyFlyLine(resLine,{x:34.01152151210911,y:4,z:-12.0},10) ;
            this.flyLinesArray.push(myline)

            let MacedoniaLabel 	   = this.get3dLabel("北马其顿",false,"20px") ;
            var flagMacedoniaModel = this.gltfLoadModel("model/public/flaggltf/scene.gltf");
            var flagMacedoniaTexture = this.changeTexture("img/flag/Macedonia.png") ;
            await flagMacedoniaModel.then((res)=>{
                let flag = res.scene.clone();
                flagAnimation = res.animations[0];
                flag.name = "Macedonia";
                flag.scale.set(4, 4, 4)
                flag.children[0].children[1].material.map = flagMacedoniaTexture;
                flag.children[0].children[1].material.map.needsUpdate = true;
                flag.add(MacedoniaLabel)
                resource.add(flag)
            })

            var eightExpFont = this.gltfLoadModel("model/date/8-20200327/scene.gltf")
            await  eightExpFont.then((res) => {
                let font  =  res.scene ;
                font.scale.set(10, 10, 10) ;
                fontAnimation = res.animations[0] ;
                font.name="20170605"
                resource.add(font)
            })

            let BalkanModel = this.gltfLoadModel("model/public/font/Balkan/seene.gltf")
            await BalkanModel.then((res)=>{
                BalkanAnimation = res.animations[0] ;
                let Balkan = res.scene ;
                Balkan.scale.set(0.7,0.7,0.7);
                Balkan.name = "Balkan" ;
                resource.add(Balkan)
            })

            // 北马其顿文字
            let MacedoniaFontModel = this.gltfLoadModel("model/public/font/Macedonia/scene.gltf")
            MacedoniaFontModel.then((res)=>{
                let font = res.scene ;
                MacedoniaAnimation = res.animations[0] ;
                font.name = "MacedoniaFont"
                resource.add(font)
            })
            // 科索沃文字
            let KosovoFontModel = this.gltfLoadModel("model/public/font/Kosovo/scene.gltf")
            KosovoFontModel.then((res)=>{
                let font = res.scene ;
                KosovoAnimation = res.animations[0] ;
                font.name = "KosovoFont"
                resource.add(font)
            })
            // 塞尔维亚
            let serbiaModel = this.gltfLoadModel("model/public/font/Serbia/scene.gltf") ;
            serbiaModel.then((res)=>{
                let font = res.scene ;
                serbiaFontAnimation = res.animations[0] ;
                font.name = "Serbia" ;
                resource.add(font) ;
            })
            this.loading = false;
            //////////////////////脚本//////////////////////
            // 台词
            this.eighthPromptText() ;
            this.$refs.Lines.src = "music/lines/eighthexp/8-0.mp3" ;
            this.$refs.Lines.play();


            newCameraPos = {
                x:-14.590759237743349,
                y:54.32559984668127,
                z:94.10765386621284
            }
            newTargetPos = {
                x:32.87414732204748,
                y:0,
                z:-8.252335754633918
            }

            this.animateCamera(this.camera.position, this.controls.target, newCameraPos, newTargetPos, 3000)


            setTimeout(()=>{
                let font = resource.getObjectByName("20170605");
                font.position.set(32.87414732204748,20,-8.252335754633918) ;
                this.onceActionPlay(fontAnimation,font)
                Group.add(font)
            },1500)

            setTimeout(()=>{
                let flag = resource.getObjectByName("Macedonia");
                flag.position.set(32.87414732204748,9,-8.252335754633918);
                this.onceActionPlay(flagAnimation,flag)
                Group.add(flag)
            },3500)

            setTimeout(()=>{
                let font = Group.getObjectByName("20170605");
                let newPos = font.position.clone() ;
                newPos.y = -40 ;
                this.recedingModel(font,font.position,newPos,2000) ;
            },4000)

            setTimeout(()=>{
                let Balkan = resource.getObjectByName("Balkan");
                this.initBalKanLand() ;
                this.colorMap("Macedonia",this.myColor.newNatoArea) ;
                Group.add(Balkan) ;
                Balkan.position.set(32.87414732204748,20,-8.252335754633918) ;
                this.onceActionPlay(BalkanAnimation,Balkan) ;
            },6100)

            setTimeout(()=>{
                let Macedonia = Group.getObjectByName("Macedonia") ;
                let newPos = Macedonia.position.clone() ;
                newPos.y = -40 ;
                this.recedingModel(Macedonia,Macedonia.position,newPos,2000)
            },12000)

            setTimeout(()=>{
                let Macedonia = resource.getObjectByName("MacedoniaFont") ;
                Macedonia.scale.set(0.1,0.1,0.1)
                Macedonia.position.set(34.96137696431783,4,-7.528797077825815) ;
                Group.add(Macedonia) ;
                this.onceActionPlay(MacedoniaAnimation,Macedonia)

                newCameraPos = { x:25.27498100019342 ,y:41.29672798809479,z:19.03580650233225 } ;
                this.animateCamera(this.camera.position,this.controls.target,newCameraPos,Macedonia.position,2000)
            },13000)

            setTimeout(()=>{
                let Kosovo = resource.getObjectByName("KosovoFont") ;
                Kosovo.rotateY(-Math.PI * 0.5)
                Kosovo.scale.set(0.08,0.08,0.08)
                Kosovo.position.set(33.99400329589844,4,-9.45643901824951) ;
                Group.add(Kosovo) ;
                this.onceActionPlay(MacedoniaAnimation,Kosovo)
            },14200)

            setTimeout(()=>{
                let font = resource.getObjectByName("Serbia") ;
                font.scale.set(0.2,0.2,0.2) ;
                font.position.set(34.01152151210911,4,-12.0) ;
                font.rotateY(-Math.PI * 0.3)
                Group.add(font) ;
                this.onceActionPlay(serbiaFontAnimation,font) ;
                Group.add(myline.group)
                this.colorMap("Serbia",this.myColor.wtoArea);
            },17200)

        }
    }
}